/*
 * FstreamC.h
 *
 *  Created on: May 21, 2012
 *      Author: marchi
 */

#ifndef FSTREAMC_H_
#define FSTREAMC_H_
#include "Fstream.h"
#include "gmxfio.h"
#include "xtcio.h"

class FstreamC: public Fstream {
	t_fileio * fin;
	void sStep();
	off_t framesize;
	int framenumber;
	void gFrameSize();
	void gFrameNumber();
public:
	FstreamC(string & file): framesize(0){
		fin=gmx_fio_open(file.c_str(),"rb");
		sStep();
		gFrameSize();
		gFrameNumber();
	}
	off_t gmFrameSize(){return framesize;}
	int gmFrameNumber(){return framenumber;}
	t_fileio * getfin(){return fin;}
	virtual bool CheckFrameNumber(int y){
		try{
			if(framenumber <= y) throw string("Number of frames is smaller than expected:");
		} catch(const string & s){
			cout << s << " it is " << framenumber-1 << " rather than " << y << endl;
			return false;
		}
		return true;
	}
	virtual void nextFrame();
	virtual void seekg(long int,string);
	virtual ios::streampos tellg();
	virtual ~FstreamC();
};

#endif /* FSTREAMC_H_ */
